Use volatile access for CoreCLR dictionary layout publication#129763
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @agocke |
Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
Co-authored-by: davidwrighton <10779849+davidwrighton@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix crash in MethodTable::MethodDataObject::FillEntryDataForAncestor
Use volatile access for CoreCLR dictionary layout publication
Jun 23, 2026
davidwrighton
approved these changes
Jun 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the publication/observation protocol for generic dictionary layout pointers in CoreCLR by switching the affected EEClass and InstantiatedMethodDesc layout-pointer accessors to use volatile semantics, reducing the chance of readers observing a partially-published update under concurrency.
Changes:
- Update
InstantiatedMethodDescdictionary-layout reads to useVolatileLoad, including the previously raw read path (GetDictLayoutRaw). - Update
InstantiatedMethodDescdictionary-layout writes to useVolatileStore. - Update
EEClassdictionary-layout reads/writes (via optional fields) to useVolatileLoad/VolatileStore.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/vm/method.hpp | Uses VolatileLoad/VolatileStore for InstantiatedMethodDesc::m_pDictLayout access across getters/setters, including the “raw” getter. |
| src/coreclr/vm/class.h | Uses VolatileLoad/VolatileStore for EEClassOptionalFields::m_pDictLayout access in EEClass accessors. |
jkotas
approved these changes
Jun 23, 2026
AndyAyersMS
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change addresses a rare CoreCLR crash in generic dictionary/method resolution caused by racing publication of dictionary layout pointers. The fix makes both publication and observation of those pointers use volatile semantics in the affected
EEClassandInstantiatedMethodDescpaths.Dictionary layout publication
EEClass::SetDictionaryLayoutandInstantiatedMethodDesc::IMD_SetDictionaryLayouttoVolatileStore.Dictionary layout reads
EEClass::GetDictionaryLayout,InstantiatedMethodDesc::IMD_GetDictionaryLayout, andInstantiatedMethodDesc::GetDictLayoutRawtoVolatileLoad.m_pDictLayout, so all readers participate in the same publication protocol.Scope